package comm;

import java.util.HashMap;
import java.util.Map;

public final class Constrant {

    /**
     * error code
     */
    //未知错误
    public static final int CODE_UNKNOW = -1;
    //请求成功
    public static final int CODE_SUCCESS = 0;
    //用户名或者密码错误
    public static final int CODE_LOGIN_FAIL = 1;
    //用户注册失败！
    public static final int CODE_REGISTER_FAIL = 2;
    //获取用户信息失败！
    public static final int CODE_USER_INFO_FAIL = 3;
    //用户名已存在
    public static final int CODE_EXISTED_USER = 4;
    //该用户不是管理员
    public static final int CODE_ADMIN_ERROR = 5;


    public static final String errorMessage(int errorCode){
        Map<Integer,String> messages = new HashMap<>();
        messages.put(CODE_LOGIN_FAIL,"未知错误");
        messages.put(CODE_LOGIN_FAIL,"用户名或者密码错误");
        messages.put(CODE_REGISTER_FAIL,"用户注册失败！");
        messages.put(CODE_USER_INFO_FAIL,"获取用户信息失败！");
        messages.put(CODE_EXISTED_USER,"用户名已存在！");
        messages.put(CODE_ADMIN_ERROR,"该用户不是管理员！");
        return messages.get(errorCode);
    }

    public final static int PAGE_SIZE = 10;
}
